package com.shop.front.controller;

import com.shop.common.aop.NotLogin;
import com.shop.common.core.AjaxResult;
import com.shop.common.enums.FileTypeEnum;
import com.shop.front.service.IIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("api/index")
@Api(tags = "主页管理")
public class IndexController {
    @Resource
    IIndexService iIndexService;

    @NotLogin
    @GetMapping("/config")
    @ApiOperation(value="公共配置")
    public AjaxResult<Map<String, Object>> config() {
        Map<String, Object> map = iIndexService.config();
        return AjaxResult.success(map);
    }

    @NotLogin
    @GetMapping("/hotSearch")
    @ApiOperation(value="热门搜索")
    public AjaxResult<List<String>> hotSearch() {
        List<String> list = iIndexService.hotSearch();
        return AjaxResult.success(list);
    }

    @GetMapping("/preUpload")
    @ApiOperation(value="OSS上传文件的预签名URL")
    public AjaxResult<Object> preUpload() {
        String type = FileTypeEnum.VOICE.getType();
        return AjaxResult.success(iIndexService.preUpload(type));
    }

}
